﻿using System;
using System.Windows.Input;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UITesting.HtmlControls;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace SDWorx.ICTCorp.TestAutomationFramework.WebFormsApplication
{
    public class TAF_BrowserWindow : BrowserWindow
    {
        public TAF_BrowserWindow(string strName)
        {
            // TODO: get the values from the DB, based on strName
            if (strName != "") this.SearchProperties[UITestControl.PropertyNames.Name] = strName;
            this.SearchProperties[UITestControl.PropertyNames.ClassName] = "IEFrame";
            if (strName != "") this.WindowTitles.Add(strName);
        }
    }

    public class TAF_HtmlFrame : HtmlFrame
    {
        public TAF_HtmlFrame(UITestControl searchLimitContainer, String strName, String strURL) : 
            base(searchLimitContainer)
        {
            this.SearchProperties[HtmlFrame.PropertyNames.Name] = strName;
            this.SearchProperties[HtmlFrame.PropertyNames.PageUrl] = strURL;

            this.WindowTitles.Add("Telefoonboekje");
        }
    }

    public class TAF_HtmlDocument : HtmlDocument
    {

        public TAF_HtmlDocument(UITestControl searchLimitContainer) :
            base(searchLimitContainer)
        {
            // set the value to the same of the parent
            if (searchLimitContainer.WindowTitles.Count > 0) this.WindowTitles.Add(searchLimitContainer.WindowTitles[0]);

        }
    }

    public class TAF_HtmlEdit : HtmlEdit
    {
        public TAF_HtmlEdit(UITestControl searchLimitContainer, String strID, String strName) :
            base(searchLimitContainer)
        {
            if (strID != "") this.SearchProperties[HtmlEdit.PropertyNames.Id] = strID;
            if (strName != "") this.SearchProperties[HtmlEdit.PropertyNames.Name] = strName;
            // set the value to the same of the parent
            if (searchLimitContainer.WindowTitles.Count > 0) this.WindowTitles.Add(searchLimitContainer.WindowTitles[0]);

        }
    }

    public class TAF_HtmlInputButton : HtmlInputButton
    {
        public TAF_HtmlInputButton(UITestControl searchLimitContainer, String strID, String strName) :
            base(searchLimitContainer)
        {
            if (strID != "") this.SearchProperties[HtmlInputButton.PropertyNames.Id] = strID;
            if (strName != "") this.SearchProperties[HtmlInputButton.PropertyNames.Name] = strName;

            // set the value to the same of the parent
            if (searchLimitContainer.WindowTitles.Count > 0) this.WindowTitles.Add(searchLimitContainer.WindowTitles[0]);

        }
    }

    public class TAF_HtmlDiv : HtmlDiv
    {
        public TAF_HtmlDiv(UITestControl searchLimitContainer, String strID, String strName) :
            base(searchLimitContainer)
        {
            if (strID != "") this.SearchProperties[HtmlDiv.PropertyNames.Id] = strID;
            if (strName != "") this.SearchProperties[HtmlDiv.PropertyNames.Name] = strName;

            // set the value to the same of the parent
            if (searchLimitContainer.WindowTitles.Count > 0) this.WindowTitles.Add(searchLimitContainer.WindowTitles[0]);

        }
    }

    public class TAF_HtmlTable : HtmlTable
    {
        public TAF_HtmlTable(UITestControl searchLimitContainer, String strID, String strName) :
            base(searchLimitContainer)
        {
            if (strID != "") this.SearchProperties[HtmlDiv.PropertyNames.Id] = strID;
            if (strName != "") this.SearchProperties[HtmlDiv.PropertyNames.Name] = strName;

            // set the value to the same of the parent
            if (searchLimitContainer.WindowTitles.Count > 0) this.WindowTitles.Add(searchLimitContainer.WindowTitles[0]);

        }
    }

    public class TAF_HtmlCell : HtmlCell
    {
        public TAF_HtmlCell(UITestControl searchLimitContainer, String RowIndex, String ColumnIndex) :
            base(searchLimitContainer)
        {
            if (ColumnIndex != "") this.SearchProperties[HtmlCell.PropertyNames.ColumnIndex] = ColumnIndex;
            if (RowIndex != "") this.SearchProperties[HtmlCell.PropertyNames.RowIndex] = RowIndex;

            // set the value to the same of the parent
            if (searchLimitContainer.WindowTitles.Count > 0) this.WindowTitles.Add(searchLimitContainer.WindowTitles[0]);

        }
    }


}
